﻿using System;
using System.Diagnostics;
using Microsoft.Practices.Mobile.ContainerModel;

namespace Lilium.ContainerModel
{
    public sealed class ContainerAdapter : IContainer
    {
        public ContainerAdapter(Container container)
        {
            if (container == null) throw new ArgumentNullException("container");

            m_Container = container;
        }

        public T Resolve<T>()
        {
            return Container.Resolve<T>();
        }

        public void Register<TService>(Func<IContainer, TService> factory)
        {
            Container.Register<TService>(c => factory(this));
        }

        #region private Container Container

        private readonly Container m_Container;

        private Container Container
        {
            [DebuggerNonUserCodeAttribute]
            get
            {
                return m_Container;
            }
        }

        #endregion
    }
}
